package com.hnu.tockmarket.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * 抽象Fragment基类
 *
 * @author hnulht
 * @since 2021-07-07
 */
public abstract class BaseFragment extends Fragment {

    private static final String TAG = "BaseFragment"; // 日志
    private Context context; // 上下文/场景

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = getActivity();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return initView();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
    }

    /**
     * 初始化视图的抽象方法
     *
     * @return View
     */
    public abstract View initView();

    /**
     * 初始化相关数据
     */
    public void initData() {

    }

}